<?php
/**
 * @version		0.2.0 joomla zmluvy $
 * @package		com_zjmluvy
 * @copyright	Copyright © 2011 - All rights reserved.
 * @license		GNU/GPL
 * @author    AdrianKo		
 * @website   http://code.google.com/p/joomla-zmluvy
 *
 *
 *1.3.2012
 */

// no direct access
defined('_JEXEC') or die('Restricted access');
  
JHTML::_('behavior.tooltip'); 
	JToolBarHelper::title( JText::_( '&nbsp;&nbsp;&nbsp;'.JText::_( 'TITLE_ZMLUVY_EDIT' )), 'zmluvy' );
  
  //*** podmienky pre zobrazenie ikony pre zmazanie dokumentov
  if (!empty($this->item->file)) {
    JToolBarHelper::customX( 'deletefile', 'delete','','Zmazat sken', false);
  }
  if (!empty($this->item->file2)) {
    JToolBarHelper::customX( 'deletefile2', 'delete','','Zmazat TXT/OCR', false);
  }
  JToolBarHelper::save();
	JToolBarHelper::apply();
	if (JRequest::getVar('edit')) {
		JToolBarHelper::cancel( 'cancel', 'Close' );
	} else {
		JToolBarHelper::cancel();
	}
//	JToolBarHelper::help( 'screen.users' );
  $editor =& JFactory::getEditor();
  
  //*** zameni hodnotu v datume z 0000-00-00 za vlastne v confug.xml
  $platnost = 0;
  if ($this->item->publish_down == '0000-00-00' || $this->item->publish_down == 0) {
    $platnost = 1;
    $this->item->publish_down = $this->nastavenie->datum_text;
  }
  if ($this->item->publish_up == '0000-00-00' || $this->item->publish_up == 0) {
    $platnost = 1;
    $this->item->publish_up = $this->nastavenie->datum_text;
  } 
  if ($this->item->datUhrady == '0000-00-00' || $this->item->datUhrady == 0) {
    $platnost = 1;
    $this->item->datUhrady = $this->nastavenie->datum_text;
  }
  if ($this->item->datum_podpisu == '0000-00-00' || $this->item->datum_podpisu == 0) {
    $platnost = 1;
    $this->item->datum_podpisu = $this->nastavenie->datum_text;
  }    
    

?>	
<form action="index.php" method="post" name="adminForm" enctype="multipart/form-data">		
  <div class="col width-60">			
    <fieldset class="adminform">				
      <legend>
        <?php echo JText::_( 'zm_EDIT_BLOK_ZMY' ); ?>
      </legend>					
      <table class="admintable">				            	
        <tr>						
          <td class="key">							
            <label for="faktura" width="100">								
              <?php echo JText::_( 'zm_CISLO_ZMLUVY' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <input id="faktura" class="text_area" name="faktura" title="<?php echo JText::_( 'Číslo zmluvy/dodatku' ); ?>" value="<?php echo $this->item->faktura; ?>" size="30" maxlength="50" />
          </td>					
        </tr>
        
        <tr> 
          <td class="key"> 
            <label>
              <?php echo JText::_( 'zm_dodatok' ); ?>
            </label>
          </td> 
          <td> 
						<?php echo $this->lists['typ']; ?><?php echo $this->lists['zmluva']; ?>
          </td>
        </tr> 

        <tr>                      	
          <td class="key">							
            <label  width="100">								
              <?php echo JText::_( 'zm_PARTNER' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">							
            <?php echo $this->lists['dod']; ?>
            <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
            <?php echo "<a title='".JText::_( '' )."' href='index.php?option=com_jzmluvy&view=upravapartner&task=edit&id[]=0'>".JText::_( 'fa_EDIT_NOVY' )."</a>" ?>
  				</td>					
        </tr>        	
        
        <tr>						
          <td class="key">							
            <label for="fulltext" width="100">								
              <?php echo JText::_( 'zm_NAZOV_ZMLUVY' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <input id="fulltext" class="text_area" name="fulltext" title="<?php echo JText::_( 'Názov zmluvy' ); ?>" value="<?php echo $this->item->fulltext; ?>" size="80" maxlength="150" />
            <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
          </td>					
        </tr>    

        <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'zm_PREDMET' ); ?>: 							
            </label>
          </td>			
          <td colspan="2">						  
            <textarea id="title" class="text_area" name="title" cols="50" rows="3" title="<?php echo JText::_( 'Predmet zmluvy' ); ?>"><?php echo $this->item->title; ?></textarea>						
            <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
          </td>					
        </tr>                                 

        <tr>						
          <td class="key">							
            <label for="suma" width="100">								
              <?php echo JText::_( 'fa_EDIT_SUMA' ); ?> <?php if($this->nastavenie->dph) { echo JText::_( 'OBJ_SDPH' ); } else { echo JText::_( 'OBJ_BEZDPH' ); } ?>:                
            </label>
          </td>						
          <td colspan="2">						  
             <input id="suma" class="text_area" name="suma" title="<?php echo JText::_( 'Suma' ); ?>" value="<?php echo $this->item->suma; ?>" size="30" maxlength="50" />										
             <input id="mena" class="text_area" name="mena" title="<?php echo JText::_( 'Mena' ); ?>" value="<?php echo $this->item->mena; ?>" size="10" maxlength="10" />
             <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
          </td>
        </tr>          	              					
    
        <?php if($this->nastavenie->zml_zodpovedna_osoba) : ?>          
        <tr>						
          <td class="key">							
            <label for="created_by_alias" width="100">								
              <?php echo JText::_( 'zm_ZODPOVEDNA_OSOBA' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						
            <?php echo $this->lists['kontakty']; ?>
          </td>					
        </tr>					
        <?php endif; ?>               		 
      </table>
    </fieldset>
           
    <fieldset class="adminform">				
      <legend>
        <?php echo JText::_( 'zm_datumy' ); ?>
      </legend>					
      <table class="admintable">	           
        <tr>						
          <td class="key">							
            <label for="datZver" width="100">								
              <?php echo JText::_( 'zm_DAT_ZVEREJNENIA' ); ?>: 							
            </label>
          </td>
          <td>					
            <?php echo JHTML::_('calendar', jzmluvyHelper::datdmy($this->item->datZver), "datZver", "datZver", '%d.%m.%Y'); ?> 
            <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
          </td>
        </tr>

        <tr>						
          <td class="key">							
          <label for="datUhrady" width="100">								
            <?php echo JText::_( 'zm_DAT_UZAVRETIA' ); ?>: 							
            </label>
          </td>
          <td>
            <?php echo JHTML::_('calendar', jzmluvyHelper::datdmy($this->item->datUhrady), "datUhrady", "datUhrady", '%d.%m.%Y'); ?> 
            <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
          </td>
        </tr>	
        
        <?php if($this->nastavenie->zml_dat_podpisu) : ?>
        <tr>					
          <td class="key">							
            <label for="datum_podpisu" width="100">								
              <?php echo JText::_( 'zm_DAT_PODPISU' ); ?>: 							
            </label>
          </td>
          <td>
            <?php echo JHTML::_('calendar', jzmluvyHelper::datdmy($this->item->datum_podpisu), "datum_podpisu", "datum_podpisu", '%d.%m.%Y'); ?>     
            <?php // echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
          </td>
        </tr>
        <?php endif; ?>				
          
        <?php if($this->nastavenie->zml_dat_platnosti) : ?>
        <tr>
          <td class="key">							
            <label for="publish_down" width="100">								
              <?php echo JText::_( 'zm_DAT_PLATNOSTI' ); ?>: 							
            </label>
          </td>
          <td>
            <?php echo JHTML::_('calendar', jzmluvyHelper::datdmy($this->item->publish_down), "publish_down", "publish_down", '%d.%m.%Y'); ?> 
          </td>
        </tr>
        <?php endif; ?>
          				
        <?php if($this->nastavenie->zml_dat_ucinnosti) : ?>
        <tr>						
          <td class="key">							
            <label for="publish_up" width="100">								
               <?php echo JText::_( 'zm_DAT_UCINNOSTI' ); ?>: 							
            </label>
          </td>
          <td>
            <?php echo JHTML::_('calendar', jzmluvyHelper::datdmy($this->item->publish_up), "publish_up", "publish_up", '%d.%m.%Y'); ?>             
            <?php // echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
          </td>
        </tr>
        <?php endif; ?>
      </table>
    </fieldset>       					

    <fieldset class="adminform">				
      <legend>
        <?php echo JText::_( 'zm_DOK' ); ?>
      </legend>					
      <table class="admintable">
        <tr>						
          <td class="key">							
            <label for="file" width="100">								
              <?php echo JText::_( 'zm_EDIT_SUBOR_SKEN' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <?php if (empty($this->item->file)) { ?>							
              <input type="file" name="soubor" style="width: 300px;" />							
            <?php } else { ?>
            <?php echo jzmluvyHelper::ikona ($this->item->extension,$this->item->file).' '.$this->item->file; ?>
            <?php echo '<input type="hidden" name="soubor" value="'.$this->item->file.'" />'; ?>
            <?php } ?>
          </td>					
        </tr>					
        
        <tr>						
          <td class="key">							
            <label for="file2" width="100">								
              <?php echo JText::_( 'zm_EDIT_SUBOR_TXT' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <?php if (empty($this->item->file2)) { ?>							
              <input type="file" name="soubor2" style="width: 300px;" />							
            <?php } else { ?>
            <?php echo jzmluvyHelper::ikona ($this->item->extension2,$this->item->file2).' '.$this->item->file2; ?>
            <?php echo '<input type="hidden" name="soubor2" value="'.$this->item->file2.'" />'; ?>
            <?php } ?>
          </td>					
        </tr>           					 				
			
        <tr>						
          <td class="key">							
            <label for="poznamka" width="100">								
              <?php echo JText::_( 'zm_POZNAMKA' ); ?>: 							
            </label>
          </td>
          <td>							
            <textarea id="poznamka" class="text_area" name="poznamka" cols="55" rows="3" title="<?php echo JText::_( 'Poznámka' ); ?>"><?php echo $this->item->poznamka; ?></textarea>
          </td>
        </tr>					
      </table>			
    </fieldset>		
  </div>

  <?php //*** blok na pravo objednavatel ?>
  <div style="float:right;" class="col width-30">			
    <fieldset class="adminform">				
      <legend>
        <?php echo JText::_( 'zm_PARTNER_OBJEDNAVATEL' ); ?>
      </legend>					
      <table class="admintable">				            	
        
        <?php // ak je len jeden objednavatel ?>
        <?php if($this->nastavenie->partner_pocet_obj == 1) : ?>
        <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'zm_PARTNER_OBJEDNAVATEL' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <?php echo $this->lists['zad2']->text; ?>
          </td>					
        </tr>
        <?php endif; ?>
        
        <?php // ak je viacej objednavatelov ?>
        <?php if($this->nastavenie->partner_pocet_obj >= 2) : ?>
        <tr>                      	
          <td class="key">							
            <label  width="100">								
              <?php echo JText::_( 'zm_PARTNER_OBJEDNAVATEL_MENO' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">							
            <?php echo $this->lists['zad']; ?>
  				</td>					
        </tr>    
        <?php endif; ?>

        <tr>                      	
          <td class="key">							
            <label  width="100">								
              <?php echo JText::_( 'zm_PARTNER_OBJEDNAVATEL' ); ?>? 							
            </label>
          </td>						
          <td colspan="2">							
            <?php echo $this->lists['zadavatel']; ?>
            <?php echo jzmluvyHelper::obrazok('povinne-16.png','',JText::_( 'fa_POVINNE' )) ?>
  				</td>					
        </tr>    
      </table>
    </fieldset>
  </div>
   
  <?php //*** blok na pravo info a statistika 
  if($this->item->id != '') { ?>
  <div style="float:right;" class="col width-30">			
    <fieldset class="adminform">				
      <legend>
        <?php echo JText::_( 'Info &amp; statistika' ); ?>
      </legend>					
      <table class="admintable">				            	
        <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'Vytvoril' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <?php echo jzmluvyHelper::uzivatel($this->item->id)->vytvoril;?>
          </td>					
        </tr>
        
        <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'Datum vytvorenia' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <?php echo $this->item->created; ?>
          </td>					
        </tr>
       
        <?php if($this->item->modified != 0 ) { ?>
        <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'Upravil' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <?php echo jzmluvyHelper::uzivatel($this->item->id)->zmenil;?>
          </td>					
        </tr>
        
        <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'Datum poslednej upavy' ); ?>: 							
            </label>						</td>						
          <td colspan="2">						  
            <?php echo $this->item->modified; ?>
          </td>					
        </tr>
        <?php } ?>
        
        <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'Počet zobrazeni' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <input id="hits_detail" class="text_area" name="hits_detail" title="<?php echo JText::_( 'pocet_zobrazeni' ); ?>" value="<?php echo $this->item->hits_detail; ?>" size="10" maxlength="50" />&nbsp;krát
          </td>					
        </tr>
        
        <?php if($this->item->hits != 0 || $this->item->filename != '') { ?>
        <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'Stiahnuty scan subor' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <input id="hits" class="text_area" name="hits" title="<?php echo JText::_( 'pocet_stiahnut_scan' ); ?>" value="<?php echo $this->item->hits; ?>" size="10" maxlength="50" />&nbsp;krát
          </td>					
        </tr>
        <?php } ?> 
        
        <?php if($this->item->hits2 != 0 || $this->item->filename2 != '') { ?>
        <tr>						
          <td class="key">							
            <label for="title" width="100">								
              <?php echo JText::_( 'Stiahnuty textovy subor' ); ?>: 							
            </label>
          </td>						
          <td colspan="2">						  
            <input id="hits2" class="text_area" name="hits2" title="<?php echo JText::_( 'pocet_stiahnut_text' ); ?>" value="<?php echo $this->item->hits2; ?>" size="10" maxlength="50" />&nbsp;krát
          </td>					
        </tr>                      	
        <?php } ?>        						
      </table>
    </fieldset>
  </div>
  <?php } ?> 
		
  <div class="clr">
  </div>		
  <input type="hidden" name="option" value="com_jzmluvy" />		
  <input type="hidden" name="controller" value="upravazmluvy" />		
  <input type="hidden" name="id" value="<?php echo $this->item->id; ?>" /> 		
  <input type="hidden" name="task" value="edit" />		
  <input type="hidden" name="redirect" value="<?php //echo $redirect; ?>" />		
  <?php echo JHTML::_( 'form.token' ); ?>		
</form>